home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Day Cry
/
Day Cry CD.bin
/
oh_towns
/
taropyon
/
splib
/
splib.lzh
/
PRG
/
ZNSPLAY
/
ZNSMOV.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-10
|
3KB
|
109 lines
/*************************************************************************
* "znsmov.c"
*************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <egb.h>
#include <ugoku.h>
#include "znsplay.h"
/* graphic init */
static int moving_graph_init( int md, int x0, int y0, int x1, int y1 )
{
int x, y;
static struct _tbl_t
{ int dx, dy, vx, vy, ox, oy;
} tbl[4] =
{ { 320,240, 160,120, 0, 0 }, /* ü~1 */
{ 320,240, 0, 0, 0, 0 }, /* ü~2 */
{ 213,160, 0, 0, 54, 40 }, /* ü~3 */
{ 160,120, 0, 0, 80, 60 }, /* ü~4 */
};
struct _tbl_t *ptr;
FRAME fr; /* 640ü~480ëµû╩é╔è╖ÄZé╡é─ */
if ( md < 1 )
md = 1;
else if ( md > 4 )
md = 4;
ptr = &tbl[md-1];
if( x0 == 0 && y0 == 0 && x1 == 0 && y1 == 0 )
{
x1 = 319;
y1 = 239;
}
x = ((x0+x1+1) >> 1) - 160; /* èGé╠ÆåÉSé╠é╕éΩé≡îvÄZ */
y = ((y0+y1+1) >> 1) - 120;
ZNS_cls();
if ( DspCtrl.page0 != 10 )
{
EGB_resolution(EgbPtr,0,10);
DspCtrl.page0 = 10;
DspCtrl.scinf[0].md = 10;
EGB_displayPage(EgbPtr,1,3);
page1_palette();
}
DSP_writePage(0);
ZNS_displayStart(2,md,md); /* ëµû╩é╠ègæσ */
ZNS_displayStart(3,ptr->dx,ptr->dy); /* ò\Īëµû╩é╠æσé½é│ */
ZNS_displayStart(0,ptr->vx,ptr->vy); /* ëµû╩é╠ò\ĪèJÄnêΩé╠É▌ÆΦ */
x = ptr->ox + x;
y = ptr->ox + y;
ZNS_displayStart(1,x,y); /* ë╝æzëµû╩Æåé╠ê┌ô« */
fr.x1 = ptr->vx + (x0-x) * md;
fr.y1 = ptr->vy + (y0-y) * md;
fr.x2 = ptr->vx + (x1-x) * md + md - 1;
fr.y2 = ptr->vy + (y1-y) * md + md - 1;
ZNS_frame( &fr );
return (0);
}
int zns_play_mov( ZNSMOVE_T *znsmove )
{
int frame, x0, y0, x1, y1, wsize;
int error;
char *buf, *work;
if ( znsmove->mode == ZNS_MODE_MEMORY )
{
error = mov_memory_play_init(
znsmove->filename, ZnsNextCheck, &frame,&x0,&y0,&x1,&y1, &wsize );
} else
{
error = mov_disk_play_init(
znsmove->filename, ZnsNextCheck, &frame,&x0,&y0,&x1,&y1, &wsize );
}
if( error ) return error;
moving_graph_init( znsmove->expand, x0, y0, x1, y1 );
if ( (buf = malloc( 153600 )) == NULL )
{
return 7; /* out of memory */
}
if ( (work = malloc( wsize )) == NULL )
{
free( buf );
return 7; /* out of memory */
}
if ( znsmove->mode == ZNS_MODE_MEMORY )
error = mov_memory_play( buf, work, znsmove->filename, 0, znsmove->wait );
else
error = mov_disk_play ( buf, work, znsmove->filename, 0, znsmove->wait );
free( buf );
free( work );
return error;
}